// Generated with smithy-dart 0.3.2. DO NOT MODIFY.
// ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,unnecessary_library_name

// ignore_for_file: unused_element
library aws_json1_1_v1.json_protocol.test.operation_with_optional_input_output_operation_test_test; // ignore_for_file: no_leading_underscores_for_library_prefixes

import 'package:aws_json1_1_v1/src/json_protocol/model/operation_with_optional_input_output_input.dart';
import 'package:aws_json1_1_v1/src/json_protocol/model/operation_with_optional_input_output_output.dart';
import 'package:aws_json1_1_v1/src/json_protocol/operation/operation_with_optional_input_output_operation.dart';
import 'package:aws_signature_v4/aws_signature_v4.dart' as _i3;
import 'package:built_value/serializer.dart';
import 'package:smithy/smithy.dart' as _i4;
import 'package:smithy_test/smithy_test.dart' as _i2;
import 'package:test/test.dart' as _i1;

void main() {
  _i1.test('can_call_operation_with_no_input_or_output (request)', () async {
    await _i2.httpRequestTest(
      operation: OperationWithOptionalInputOutputOperation(
        region: 'us-east-1',
        baseUri: Uri.parse('https://example.com'),
        credentialsProvider: const _i3.AWSCredentialsProvider(
          _i3.AWSCredentials('DUMMY-ACCESS-KEY-ID', 'DUMMY-SECRET-ACCESS-KEY'),
        ),
      ),
      testCase: const _i2.HttpRequestTestCase(
        id: 'can_call_operation_with_no_input_or_output',
        documentation: 'Can call operations with no input or output',
        protocol: _i4.ShapeId(namespace: 'aws.protocols', shape: 'awsJson1_1'),
        authScheme: null,
        body: '{}',
        bodyMediaType: 'application/json',
        params: {},
        vendorParamsShape: null,
        vendorParams: {},
        headers: {
          'Content-Type': 'application/x-amz-json-1.1',
          'X-Amz-Target': 'JsonProtocol.OperationWithOptionalInputOutput',
        },
        forbidHeaders: [],
        requireHeaders: [],
        tags: [],
        appliesTo: null,
        method: 'POST',
        uri: '/',
        host: null,
        resolvedHost: null,
        queryParams: [],
        forbidQueryParams: [],
        requireQueryParams: [],
      ),
      inputSerializers: const [
        OperationWithOptionalInputOutputInputAwsJson11Serializer(),
      ],
    );
  });
  _i1.test('can_call_operation_with_optional_input (request)', () async {
    await _i2.httpRequestTest(
      operation: OperationWithOptionalInputOutputOperation(
        region: 'us-east-1',
        baseUri: Uri.parse('https://example.com'),
        credentialsProvider: const _i3.AWSCredentialsProvider(
          _i3.AWSCredentials('DUMMY-ACCESS-KEY-ID', 'DUMMY-SECRET-ACCESS-KEY'),
        ),
      ),
      testCase: const _i2.HttpRequestTestCase(
        id: 'can_call_operation_with_optional_input',
        documentation: 'Can invoke operations with optional input',
        protocol: _i4.ShapeId(namespace: 'aws.protocols', shape: 'awsJson1_1'),
        authScheme: null,
        body: '{"Value":"Hi"}',
        bodyMediaType: 'application/json',
        params: {'Value': 'Hi'},
        vendorParamsShape: null,
        vendorParams: {},
        headers: {
          'Content-Type': 'application/x-amz-json-1.1',
          'X-Amz-Target': 'JsonProtocol.OperationWithOptionalInputOutput',
        },
        forbidHeaders: [],
        requireHeaders: [],
        tags: [],
        appliesTo: null,
        method: 'POST',
        uri: '/',
        host: null,
        resolvedHost: null,
        queryParams: [],
        forbidQueryParams: [],
        requireQueryParams: [],
      ),
      inputSerializers: const [
        OperationWithOptionalInputOutputInputAwsJson11Serializer(),
      ],
    );
  });
}

class OperationWithOptionalInputOutputInputAwsJson11Serializer
    extends
        _i4.StructuredSmithySerializer<OperationWithOptionalInputOutputInput> {
  const OperationWithOptionalInputOutputInputAwsJson11Serializer()
    : super('OperationWithOptionalInputOutputInput');

  @override
  Iterable<Type> get types => const [OperationWithOptionalInputOutputInput];

  @override
  Iterable<_i4.ShapeId> get supportedProtocols => const [
    _i4.ShapeId(namespace: 'aws.protocols', shape: 'awsJson1_1'),
  ];

  @override
  OperationWithOptionalInputOutputInput deserialize(
    Serializers serializers,
    Iterable<Object?> serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = OperationWithOptionalInputOutputInputBuilder();
    final iterator = serialized.iterator;
    while (iterator.moveNext()) {
      final key = iterator.current as String;
      iterator.moveNext();
      final value = iterator.current;
      if (value == null) {
        continue;
      }
      switch (key) {
        case 'Value':
          result.value =
              (serializers.deserialize(
                    value,
                    specifiedType: const FullType(String),
                  )
                  as String);
      }
    }

    return result.build();
  }

  @override
  Iterable<Object?> serialize(
    Serializers serializers,
    OperationWithOptionalInputOutputInput object, {
    FullType specifiedType = FullType.unspecified,
  }) {
    throw StateError('Not supported for tests');
  }
}

class OperationWithOptionalInputOutputOutputAwsJson11Serializer
    extends
        _i4.StructuredSmithySerializer<OperationWithOptionalInputOutputOutput> {
  const OperationWithOptionalInputOutputOutputAwsJson11Serializer()
    : super('OperationWithOptionalInputOutputOutput');

  @override
  Iterable<Type> get types => const [OperationWithOptionalInputOutputOutput];

  @override
  Iterable<_i4.ShapeId> get supportedProtocols => const [
    _i4.ShapeId(namespace: 'aws.protocols', shape: 'awsJson1_1'),
  ];

  @override
  OperationWithOptionalInputOutputOutput deserialize(
    Serializers serializers,
    Iterable<Object?> serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = OperationWithOptionalInputOutputOutputBuilder();
    final iterator = serialized.iterator;
    while (iterator.moveNext()) {
      final key = iterator.current as String;
      iterator.moveNext();
      final value = iterator.current;
      if (value == null) {
        continue;
      }
      switch (key) {
        case 'Value':
          result.value =
              (serializers.deserialize(
                    value,
                    specifiedType: const FullType(String),
                  )
                  as String);
      }
    }

    return result.build();
  }

  @override
  Iterable<Object?> serialize(
    Serializers serializers,
    OperationWithOptionalInputOutputOutput object, {
    FullType specifiedType = FullType.unspecified,
  }) {
    throw StateError('Not supported for tests');
  }
}
